inline const size_t order::Calc_Capacity(const size_t _capacity)
{
	size_t add_block = (bool) (_capacity % size_block) * size_block;
	size_t base_capacity = (_capacity / size_block)* size_block;
	return (base_capacity + add_block);
}

inline const int order::Max (int a, int b)
{
	return (a > b) ? a : b;
}

order::order(const size_t _capacity, const size_t _size_block)
{
	size_block = _size_block;
	size = _capacity;
	capacity = Calc_Capacity(_capacity);
	data = new int [capacity];
}

const order & order:: operator = (const int number)
{
	for (size_t i= 0; i< size; ++i) {data[i]= number;}
	return *this;
}	

const order & order:: operator = (const order &_cl)
{
	for (size_t i= 0; i< this->size; ++i) {this->data[i] = _cl.data[i];}
	return *this;
}

order::order(const order & cp_obj)
{
	//order new_obj(/*cp_obj.capacity, cp_obj.size_block*/10,3);
	//new_obj = cp_obj;
	//for (size_t i= 0; i< cp_obj.capacity; ++i) {new_obj.data[i] = cp_obj.data[i];}

	size_block = cp_obj.size_block;
	size = cp_obj.size;
	capacity = cp_obj.capacity;
	data = new int [capacity];
	
	for (size_t i= 0; i< capacity; ++i) {data[i] = cp_obj.data[i];}
}

int & order:: operator [] (int index)
{
	//if (size == 0) return 0;
	if (index < 0) index = 0;
	if (index >= size) index = size-1;
	
	return data[index];
}

const order order:: operator + (const order &_cl)
{
	size_t new_size_block = Max(this->size_block, _cl.size_block);
	size_t new_capacity = (this->size + _cl.size);

	order new_obj(new_capacity, new_size_block);
	
	size_t i= 0;
	for ( ; i< this->size; ++i) {new_obj.data[i] = this->data[i];}
	for (size_t j= 0; i< new_obj.size; ++i, ++j) {new_obj.data[i] = _cl.data[j];}
	return new_obj;
	
	//size_block = Max(this->size_block, _cl.size_block);
	//size = this->size + _cl.size;
	//capacity = Calc_Capacity (size);
	//data = new int [capacity];
}

const order & order:: operator + (const int number)
{
	for (size_t i= 0; i< this->size; ++i) {this->data[i] += number;}
	return *this;
}

const order & order:: operator - (const int number)
{
	for (size_t i= 0; i< this->size; ++i) {this->data[i] -= number;}
	return *this;
}


order & order:: operator ++ (int number)
{
	if(size < capacity) {++size; data[size] = number;}
	else 
	{
		order new_obj(capacity+1, size_block);
		new_obj = *this;
		new_obj[++size] = number;
		order * tmp;
		tmp = new_obj;
		new_obj = this;
		this = tmp;
	}
	return * this;
}
/*
order::order & operator -- (int number)
{

};
*/


void order::Show(size_t count_col)
{
	for (size_t i= 0; i< size; ++i)
	{
		((i+1)%count_col) ? cout << data[i] << "\t" : cout << data[i] << endl;
	}
	cout << endl << "----------------------" << endl;
	cout << "Block size = " << size_block << endl;
	cout << "Size = " << size << endl;
	cout << "Capacity = " << capacity << endl;
	
}

order::~ order ()
{
	delete [] data;
}
